<?php
/*
 * 手机客户端 秀场浏览作品评论接口
 * 传入参数 
 * 2013-12-011
 */
include "inc/public_header.php";

//用户信息处理函数
include "func/user.php";				

//构建返回值
$reJson = array();
 
$page			= $_REQUEST["page"]; 			//页数，第一页为0
$pagesize		= $_REQUEST["pagesize"];		//每页记录数
$commentId	    = $_REQUEST["commentId"];		//作品id	
$hd_id			= $_REQUEST["hd_id"];			//活动主键

if(!isset($page)){
	$page = 0;
}
if(!isset($pagesize)){
	$pagesize = 20; //默认每页20条
}

$reJson["success"] = "1";

//获取回复总数
$sql= "
		SELECT COUNT(id) as ct from new_weituo_huifu WHERE dr='0' and pid='".$commentId."'
	";
	$db->query($sql);
	$db->next_record();
	$reJson["count"] = $db->f("ct"); 

	//获取对应的回复数据
	$sql="
		select
			c.nickname 
			,a.acontent 
			,a.id
			,a.ctime 
			,f.mobile
		from 
			new_weituo_huifu a
			inner join new_weituo_comment b on a.pid=b.id
			left join new_weituo_person c on a.uid=c.uid
			inner join user_base f on f.uid=a.uid
		where
			a.dr='0' and
			
			b.id='".$commentId."'
			and b.dr='0'
	";
if(isset($hd_id) && $hd_id!=""){
	$sql = $sql." and a.hd_id='".$hd_id."' ";
}
$sql = $sql." order by a.ctime desc ";
$sql = $sql." limit ".($page * $pagesize).",".$pagesize;
$db->query($sql);
$hfListArr = array();		
while($db->next_record()){
	$nickName = $db->f("nickname");
	if($nickName==null){
		$nickName = user_fix_mobile($db->f("mobile"));
	}
	$hfListArr[] = array(
		"userName"			=>$nickName						//回复人昵称
		,"replyContent"		=>$db->f("acontent")			//回复内容
		,"replyDate" 		=>$db->f("ctime")				//回复时间
		,"replyId"			=>$db->f("id")					//回复id
	);
}
	
$reJson["list"]= $hfListArr;
echo json_encode($reJson);
?>

